unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, UniProvider,
  PostgreSQLUniProvider, Data.DB, DBAccess, Uni,Thrad_SaveData, Data.Win.ADODB,
  frxClass, frxDesgn, SQLServerUniProvider,System.IniFiles,Class_Card,Class_KzDebug;

type
  TForm1 = class(TForm)
    Btnv_1: TButton;
    con1: TUniConnection;
    PostgreSQLUniProvider1: TPostgreSQLUniProvider;
    con2: TADOConnection;
    cmd1: TADOCommand;
    Btnv_2: TButton;
    frxReport_1: TfrxReport;
    frxDesigner1: TfrxDesigner;
    SQLServerUniProvider1: TSQLServerUniProvider;
    procedure Btnv_1Click(Sender: TObject);
    procedure Btnv_2Click(Sender: TObject);
  private
  public
    //for tkzthrad
    procedure OnKzThradGetMaxProgress(Sender: TObject;AMaxProgress:Integer);
    procedure OnKzThradGetOneProgress(Sender: TObject;AOneProgress:Integer);
    procedure OnKzThradGetTxtProgress(Sender: TObject;ATxtProgress:string);
    procedure OnKzThradGetMsgProgress(Sender: TObject;AMsgProgress:string;AVarProgress:array of Variant);
    procedure OnTerminate(Sender:TObject);
  end;

var
  Form1: TForm1;

implementation

uses
  Class_KzUtils;

{$R *.dfm}

procedure TForm1.Btnv_1Click(Sender: TObject);
var
  ThradA:TThradSaveData;
begin
  ThradA:=TThradSaveData.Create;
  ThradA.FUniC := Self.con1;

  ThradA.OnKzThradGetMaxProgress:=OnKzThradGetMaxProgress;
  ThradA.OnKzThradGetOneProgress:=OnKzThradGetOneProgress;
  ThradA.OnKzThradGetTxtProgress:=OnKzThradGetTxtProgress;

  ThradA.OnKzThradGetMsgProgress:=OnKzThradGetMsgProgress;
  ThradA.OnTerminate            :=OnTerminate;
  ThradA.FreeOnTerminate        :=True;

  ThradA.Resume;
end;

procedure TForm1.Btnv_2Click(Sender: TObject);
var
  cINX:Integer;
  cCard:TCARD;
  HashCard:THashedStringList;
begin
  {#self.frxReport_1.LoadFromFile(TKzUtils.ExePath+'kzdemo.fr3');
  self.frxReport_1.DesignReport();}

  HashCard:=THashedStringList.Create;

  KzDebug.Started;
  KzDebug.TickLog('V1');
  TCARD.ListDB('SELECT CARD_CODE,CARD_NAME,CARD_ZCTM,CARD_ZCYZ FROM TBL_CARD ORDER BY CARD_CODE',['CARD_CODE'],self.con1,TStringList(HashCard));
  KzDebug.TickLog('V2');
  //cINX:=HashCard.IndexOf('06015310302000365');
  cINX:=HashCard.IndexOf('11060410301000003');
  if cINX<>-1then
  begin
    cCard:=TCARD(HashCard.Objects[cINX]);
    KzDebug.TickFmt('V3:%S',[cCard.CARDNAME]);
  end;

  TKzUtils.TryFreeAndNil(HashCard);
end;

procedure TForm1.OnKzThradGetMaxProgress(Sender: TObject;
  AMaxProgress: Integer);
begin

end;

procedure TForm1.OnKzThradGetMsgProgress(Sender: TObject; AMsgProgress: string;
  AVarProgress: array of Variant);
begin
  ShowMessage('TRUE');
end;

procedure TForm1.OnKzThradGetOneProgress(Sender: TObject;
  AOneProgress: Integer);
begin

end;

procedure TForm1.OnKzThradGetTxtProgress(Sender: TObject; ATxtProgress: string);
begin

end;

procedure TForm1.OnTerminate(Sender: TObject);
begin

end;

end.
